<?php

namespace App\VO\UserOrder;

use App\BO\OrderStatus\OrderStateDefinition;
use App\VO\UserOrder\MetaInfo\OrderInfo;

class UserOrderShowVO
{
    /**
     * @var OrderInfo
     */
    public $order;

    /**
     * 取消订单原因
     * @var array
     */
    public $cancelOptions = [];

    /**
     * 申请退款的原因
     * @var array
     */
    public $refundOptions = [];

    public function __construct(int $orderState)
    {
        switch ($orderState) {
            case OrderStateDefinition::STATE_WAITING_PAY:
                $this->setCancelOptions();
                break;
            case OrderStateDefinition::STATE_WAITING_DISTRIBUTION:
                $this->setRefundOptions();
                break;
        }
    }

    /**
     * @param OrderInfo $order
     */
    public function setOrder(OrderInfo $order): void
    {
        $this->order = $order;
    }

    private function setRefundOptions()
    {
        $this->refundOptions = [
            ['id' => 1 , 'value' => '拍错了'],
            ['id' => 2 , 'value' => '无人上门'],
            ['id' => 3 , 'value' => '预约时间问题'],
            ['id' => 4 , 'value' => '我不想下单了'],
            ['id' => 5 , 'value' => '信息填错重新下单'],
            ['id' => 6 , 'value' => '付款遇到问题'],
            ['id' => 7 , 'value' => '其他原因'],
        ];
    }

    private function setCancelOptions(): void
    {
        $this->cancelOptions = [
            ['id' => 1 , 'value' => '拍错了'],
            ['id' => 2 , 'value' => '无人上门'],
            ['id' => 3 , 'value' => '预约时间问题'],
            ['id' => 4 , 'value' => '我不想下单了'],
            ['id' => 5 , 'value' => '信息填错重新下单'],
            ['id' => 6 , 'value' => '付款遇到问题'],
            ['id' => 7 , 'value' => '其他原因'],
        ];
    }
}
